
/*
'===============================================================================
'  Generated From - CSharp_dOOdads_BusinessEntity.vbgen
' 
'  ** IMPORTANT  ** 
'  How to Generate your stored procedures:
' 
'  SQL        = SQL_StoredProcs.vbgen
'  ACCESS     = Access_StoredProcs.vbgen
'  ORACLE     = Oracle_StoredProcs.vbgen
'  FIREBIRD   = FirebirdStoredProcs.vbgen
'  POSTGRESQL = PostgreSQL_StoredProcs.vbgen
'
'  The supporting base class SqlClientEntity is in the Architecture directory in "dOOdads".
'  
'  This object is 'abstract' which means you need to inherit from it to be able
'  to instantiate it.  This is very easilly done. You can override properties and
'  methods in your derived class, this allows you to regenerate this class at any
'  time and not worry about overwriting custom code. 
'
'  NEVER EDIT THIS FILE.
'
'  public class YourObject :  _YourObject
'  {
'
'  }
'
'===============================================================================
*/

// Generated by MyGeneration Version # (1.3.0.3)

using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using System.Collections.Specialized;

using MyGeneration.dOOdads;

namespace Camelio.DAL
{
	public abstract class _Suppliers : SqlClientEntity
	{
		public _Suppliers()
		{
			this.QuerySource = "Suppliers";
			this.MappingName = "Suppliers";

		}	

		//=================================================================
		//  public Overrides void AddNew()
		//=================================================================
		//
		//=================================================================
		public override void AddNew()
		{
			base.AddNew();
			
		}
		
		
		public override void FlushData()
		{
			this._whereClause = null;
			this._aggregateClause = null;
			base.FlushData();
		}
		
		//=================================================================
		//  	public Function LoadAll() As Boolean
		//=================================================================
		//  Loads all of the records in the database, and sets the currentRow to the first row
		//=================================================================
		public bool LoadAll() 
		{
			ListDictionary parameters = null;
			
			return base.LoadFromSql("[" + this.SchemaStoredProcedure + "proc_SuppliersLoadAll]", parameters);
		}
	
		//=================================================================
		// public Overridable Function LoadByPrimaryKey()  As Boolean
		//=================================================================
		//  Loads a single row of via the primary key
		//=================================================================
		public virtual bool LoadByPrimaryKey(int SupplierID)
		{
			ListDictionary parameters = new ListDictionary();
			parameters.Add(Parameters.SupplierID, SupplierID);

		
			return base.LoadFromSql("[" + this.SchemaStoredProcedure + "proc_SuppliersLoadByPrimaryKey]", parameters);
		}
		
		#region Parameters
		protected class Parameters
		{
			
			public static SqlParameter SupplierID
			{
				get
				{
					return new SqlParameter("@SupplierID", SqlDbType.Int, 0);
				}
			}
			
			public static SqlParameter SupplierName
			{
				get
				{
					return new SqlParameter("@SupplierName", SqlDbType.NVarChar, 50);
				}
			}
			
			public static SqlParameter SupplierPhone
			{
				get
				{
					return new SqlParameter("@SupplierPhone", SqlDbType.NVarChar, 50);
				}
			}
			
			public static SqlParameter SupplierTotalBalance
			{
				get
				{
					return new SqlParameter("@SupplierTotalBalance", SqlDbType.Float, 0);
				}
			}
			
			public static SqlParameter SupplierPaidBalance
			{
				get
				{
					return new SqlParameter("@SupplierPaidBalance", SqlDbType.Float, 0);
				}
			}
			
			public static SqlParameter SupplierRemainBalance
			{
				get
				{
					return new SqlParameter("@SupplierRemainBalance", SqlDbType.Float, 0);
				}
			}
			
		}
		#endregion		
	
		#region ColumnNames
		public class ColumnNames
		{  
            public const string SupplierID = "SupplierID";
            public const string SupplierName = "SupplierName";
            public const string SupplierPhone = "SupplierPhone";
            public const string SupplierTotalBalance = "SupplierTotalBalance";
            public const string SupplierPaidBalance = "SupplierPaidBalance";
            public const string SupplierRemainBalance = "SupplierRemainBalance";

			static public string ToPropertyName(string columnName)
			{
				if(ht == null)
				{
					ht = new Hashtable();
					
					ht[SupplierID] = _Suppliers.PropertyNames.SupplierID;
					ht[SupplierName] = _Suppliers.PropertyNames.SupplierName;
					ht[SupplierPhone] = _Suppliers.PropertyNames.SupplierPhone;
					ht[SupplierTotalBalance] = _Suppliers.PropertyNames.SupplierTotalBalance;
					ht[SupplierPaidBalance] = _Suppliers.PropertyNames.SupplierPaidBalance;
					ht[SupplierRemainBalance] = _Suppliers.PropertyNames.SupplierRemainBalance;

				}
				return (string)ht[columnName];
			}

			static private Hashtable ht = null;			 
		}
		#endregion
		
		#region PropertyNames
		public class PropertyNames
		{  
            public const string SupplierID = "SupplierID";
            public const string SupplierName = "SupplierName";
            public const string SupplierPhone = "SupplierPhone";
            public const string SupplierTotalBalance = "SupplierTotalBalance";
            public const string SupplierPaidBalance = "SupplierPaidBalance";
            public const string SupplierRemainBalance = "SupplierRemainBalance";

			static public string ToColumnName(string propertyName)
			{
				if(ht == null)
				{
					ht = new Hashtable();
					
					ht[SupplierID] = _Suppliers.ColumnNames.SupplierID;
					ht[SupplierName] = _Suppliers.ColumnNames.SupplierName;
					ht[SupplierPhone] = _Suppliers.ColumnNames.SupplierPhone;
					ht[SupplierTotalBalance] = _Suppliers.ColumnNames.SupplierTotalBalance;
					ht[SupplierPaidBalance] = _Suppliers.ColumnNames.SupplierPaidBalance;
					ht[SupplierRemainBalance] = _Suppliers.ColumnNames.SupplierRemainBalance;

				}
				return (string)ht[propertyName];
			}

			static private Hashtable ht = null;			 
		}			 
		#endregion	

		#region StringPropertyNames
		public class StringPropertyNames
		{  
            public const string SupplierID = "s_SupplierID";
            public const string SupplierName = "s_SupplierName";
            public const string SupplierPhone = "s_SupplierPhone";
            public const string SupplierTotalBalance = "s_SupplierTotalBalance";
            public const string SupplierPaidBalance = "s_SupplierPaidBalance";
            public const string SupplierRemainBalance = "s_SupplierRemainBalance";

		}
		#endregion		
		
		#region Properties
	
		public virtual int SupplierID
	    {
			get
	        {
				return base.Getint(ColumnNames.SupplierID);
			}
			set
	        {
				base.Setint(ColumnNames.SupplierID, value);
			}
		}

		public virtual string SupplierName
	    {
			get
	        {
				return base.Getstring(ColumnNames.SupplierName);
			}
			set
	        {
				base.Setstring(ColumnNames.SupplierName, value);
			}
		}

		public virtual string SupplierPhone
	    {
			get
	        {
				return base.Getstring(ColumnNames.SupplierPhone);
			}
			set
	        {
				base.Setstring(ColumnNames.SupplierPhone, value);
			}
		}

		public virtual double SupplierTotalBalance
	    {
			get
	        {
				return base.Getdouble(ColumnNames.SupplierTotalBalance);
			}
			set
	        {
				base.Setdouble(ColumnNames.SupplierTotalBalance, value);
			}
		}

		public virtual double SupplierPaidBalance
	    {
			get
	        {
				return base.Getdouble(ColumnNames.SupplierPaidBalance);
			}
			set
	        {
				base.Setdouble(ColumnNames.SupplierPaidBalance, value);
			}
		}

		public virtual double SupplierRemainBalance
	    {
			get
	        {
				return base.Getdouble(ColumnNames.SupplierRemainBalance);
			}
			set
	        {
				base.Setdouble(ColumnNames.SupplierRemainBalance, value);
			}
		}


		#endregion
		
		#region String Properties
	
		public virtual string s_SupplierID
	    {
			get
	        {
				return this.IsColumnNull(ColumnNames.SupplierID) ? string.Empty : base.GetintAsString(ColumnNames.SupplierID);
			}
			set
	        {
				if(string.Empty == value)
					this.SetColumnNull(ColumnNames.SupplierID);
				else
					this.SupplierID = base.SetintAsString(ColumnNames.SupplierID, value);
			}
		}

		public virtual string s_SupplierName
	    {
			get
	        {
				return this.IsColumnNull(ColumnNames.SupplierName) ? string.Empty : base.GetstringAsString(ColumnNames.SupplierName);
			}
			set
	        {
				if(string.Empty == value)
					this.SetColumnNull(ColumnNames.SupplierName);
				else
					this.SupplierName = base.SetstringAsString(ColumnNames.SupplierName, value);
			}
		}

		public virtual string s_SupplierPhone
	    {
			get
	        {
				return this.IsColumnNull(ColumnNames.SupplierPhone) ? string.Empty : base.GetstringAsString(ColumnNames.SupplierPhone);
			}
			set
	        {
				if(string.Empty == value)
					this.SetColumnNull(ColumnNames.SupplierPhone);
				else
					this.SupplierPhone = base.SetstringAsString(ColumnNames.SupplierPhone, value);
			}
		}

		public virtual string s_SupplierTotalBalance
	    {
			get
	        {
				return this.IsColumnNull(ColumnNames.SupplierTotalBalance) ? string.Empty : base.GetdoubleAsString(ColumnNames.SupplierTotalBalance);
			}
			set
	        {
				if(string.Empty == value)
					this.SetColumnNull(ColumnNames.SupplierTotalBalance);
				else
					this.SupplierTotalBalance = base.SetdoubleAsString(ColumnNames.SupplierTotalBalance, value);
			}
		}

		public virtual string s_SupplierPaidBalance
	    {
			get
	        {
				return this.IsColumnNull(ColumnNames.SupplierPaidBalance) ? string.Empty : base.GetdoubleAsString(ColumnNames.SupplierPaidBalance);
			}
			set
	        {
				if(string.Empty == value)
					this.SetColumnNull(ColumnNames.SupplierPaidBalance);
				else
					this.SupplierPaidBalance = base.SetdoubleAsString(ColumnNames.SupplierPaidBalance, value);
			}
		}

		public virtual string s_SupplierRemainBalance
	    {
			get
	        {
				return this.IsColumnNull(ColumnNames.SupplierRemainBalance) ? string.Empty : base.GetdoubleAsString(ColumnNames.SupplierRemainBalance);
			}
			set
	        {
				if(string.Empty == value)
					this.SetColumnNull(ColumnNames.SupplierRemainBalance);
				else
					this.SupplierRemainBalance = base.SetdoubleAsString(ColumnNames.SupplierRemainBalance, value);
			}
		}


		#endregion		
	
		#region Where Clause
		public class WhereClause
		{
			public WhereClause(BusinessEntity entity)
			{
				this._entity = entity;
			}
			
			public TearOffWhereParameter TearOff
			{
				get
				{
					if(_tearOff == null)
					{
						_tearOff = new TearOffWhereParameter(this);
					}

					return _tearOff;
				}
			}

			#region WhereParameter TearOff's
			public class TearOffWhereParameter
			{
				public TearOffWhereParameter(WhereClause clause)
				{
					this._clause = clause;
				}
				
				
				public WhereParameter SupplierID
				{
					get
					{
							WhereParameter where = new WhereParameter(ColumnNames.SupplierID, Parameters.SupplierID);
							this._clause._entity.Query.AddWhereParameter(where);
							return where;
					}
				}

				public WhereParameter SupplierName
				{
					get
					{
							WhereParameter where = new WhereParameter(ColumnNames.SupplierName, Parameters.SupplierName);
							this._clause._entity.Query.AddWhereParameter(where);
							return where;
					}
				}

				public WhereParameter SupplierPhone
				{
					get
					{
							WhereParameter where = new WhereParameter(ColumnNames.SupplierPhone, Parameters.SupplierPhone);
							this._clause._entity.Query.AddWhereParameter(where);
							return where;
					}
				}

				public WhereParameter SupplierTotalBalance
				{
					get
					{
							WhereParameter where = new WhereParameter(ColumnNames.SupplierTotalBalance, Parameters.SupplierTotalBalance);
							this._clause._entity.Query.AddWhereParameter(where);
							return where;
					}
				}

				public WhereParameter SupplierPaidBalance
				{
					get
					{
							WhereParameter where = new WhereParameter(ColumnNames.SupplierPaidBalance, Parameters.SupplierPaidBalance);
							this._clause._entity.Query.AddWhereParameter(where);
							return where;
					}
				}

				public WhereParameter SupplierRemainBalance
				{
					get
					{
							WhereParameter where = new WhereParameter(ColumnNames.SupplierRemainBalance, Parameters.SupplierRemainBalance);
							this._clause._entity.Query.AddWhereParameter(where);
							return where;
					}
				}


				private WhereClause _clause;
			}
			#endregion
		
			public WhereParameter SupplierID
		    {
				get
		        {
					if(_SupplierID_W == null)
	        	    {
						_SupplierID_W = TearOff.SupplierID;
					}
					return _SupplierID_W;
				}
			}

			public WhereParameter SupplierName
		    {
				get
		        {
					if(_SupplierName_W == null)
	        	    {
						_SupplierName_W = TearOff.SupplierName;
					}
					return _SupplierName_W;
				}
			}

			public WhereParameter SupplierPhone
		    {
				get
		        {
					if(_SupplierPhone_W == null)
	        	    {
						_SupplierPhone_W = TearOff.SupplierPhone;
					}
					return _SupplierPhone_W;
				}
			}

			public WhereParameter SupplierTotalBalance
		    {
				get
		        {
					if(_SupplierTotalBalance_W == null)
	        	    {
						_SupplierTotalBalance_W = TearOff.SupplierTotalBalance;
					}
					return _SupplierTotalBalance_W;
				}
			}

			public WhereParameter SupplierPaidBalance
		    {
				get
		        {
					if(_SupplierPaidBalance_W == null)
	        	    {
						_SupplierPaidBalance_W = TearOff.SupplierPaidBalance;
					}
					return _SupplierPaidBalance_W;
				}
			}

			public WhereParameter SupplierRemainBalance
		    {
				get
		        {
					if(_SupplierRemainBalance_W == null)
	        	    {
						_SupplierRemainBalance_W = TearOff.SupplierRemainBalance;
					}
					return _SupplierRemainBalance_W;
				}
			}

			private WhereParameter _SupplierID_W = null;
			private WhereParameter _SupplierName_W = null;
			private WhereParameter _SupplierPhone_W = null;
			private WhereParameter _SupplierTotalBalance_W = null;
			private WhereParameter _SupplierPaidBalance_W = null;
			private WhereParameter _SupplierRemainBalance_W = null;

			public void WhereClauseReset()
			{
				_SupplierID_W = null;
				_SupplierName_W = null;
				_SupplierPhone_W = null;
				_SupplierTotalBalance_W = null;
				_SupplierPaidBalance_W = null;
				_SupplierRemainBalance_W = null;

				this._entity.Query.FlushWhereParameters();

			}
	
			private BusinessEntity _entity;
			private TearOffWhereParameter _tearOff;
			
		}
	
		public WhereClause Where
		{
			get
			{
				if(_whereClause == null)
				{
					_whereClause = new WhereClause(this);
				}
		
				return _whereClause;
			}
		}
		
		private WhereClause _whereClause = null;	
		#endregion
	
		#region Aggregate Clause
		public class AggregateClause
		{
			public AggregateClause(BusinessEntity entity)
			{
				this._entity = entity;
			}
			
			public TearOffAggregateParameter TearOff
			{
				get
				{
					if(_tearOff == null)
					{
						_tearOff = new TearOffAggregateParameter(this);
					}

					return _tearOff;
				}
			}

			#region AggregateParameter TearOff's
			public class TearOffAggregateParameter
			{
				public TearOffAggregateParameter(AggregateClause clause)
				{
					this._clause = clause;
				}
				
				
				public AggregateParameter SupplierID
				{
					get
					{
							AggregateParameter aggregate = new AggregateParameter(ColumnNames.SupplierID, Parameters.SupplierID);
							this._clause._entity.Query.AddAggregateParameter(aggregate);
							return aggregate;
					}
				}

				public AggregateParameter SupplierName
				{
					get
					{
							AggregateParameter aggregate = new AggregateParameter(ColumnNames.SupplierName, Parameters.SupplierName);
							this._clause._entity.Query.AddAggregateParameter(aggregate);
							return aggregate;
					}
				}

				public AggregateParameter SupplierPhone
				{
					get
					{
							AggregateParameter aggregate = new AggregateParameter(ColumnNames.SupplierPhone, Parameters.SupplierPhone);
							this._clause._entity.Query.AddAggregateParameter(aggregate);
							return aggregate;
					}
				}

				public AggregateParameter SupplierTotalBalance
				{
					get
					{
							AggregateParameter aggregate = new AggregateParameter(ColumnNames.SupplierTotalBalance, Parameters.SupplierTotalBalance);
							this._clause._entity.Query.AddAggregateParameter(aggregate);
							return aggregate;
					}
				}

				public AggregateParameter SupplierPaidBalance
				{
					get
					{
							AggregateParameter aggregate = new AggregateParameter(ColumnNames.SupplierPaidBalance, Parameters.SupplierPaidBalance);
							this._clause._entity.Query.AddAggregateParameter(aggregate);
							return aggregate;
					}
				}

				public AggregateParameter SupplierRemainBalance
				{
					get
					{
							AggregateParameter aggregate = new AggregateParameter(ColumnNames.SupplierRemainBalance, Parameters.SupplierRemainBalance);
							this._clause._entity.Query.AddAggregateParameter(aggregate);
							return aggregate;
					}
				}


				private AggregateClause _clause;
			}
			#endregion
		
			public AggregateParameter SupplierID
		    {
				get
		        {
					if(_SupplierID_W == null)
	        	    {
						_SupplierID_W = TearOff.SupplierID;
					}
					return _SupplierID_W;
				}
			}

			public AggregateParameter SupplierName
		    {
				get
		        {
					if(_SupplierName_W == null)
	        	    {
						_SupplierName_W = TearOff.SupplierName;
					}
					return _SupplierName_W;
				}
			}

			public AggregateParameter SupplierPhone
		    {
				get
		        {
					if(_SupplierPhone_W == null)
	        	    {
						_SupplierPhone_W = TearOff.SupplierPhone;
					}
					return _SupplierPhone_W;
				}
			}

			public AggregateParameter SupplierTotalBalance
		    {
				get
		        {
					if(_SupplierTotalBalance_W == null)
	        	    {
						_SupplierTotalBalance_W = TearOff.SupplierTotalBalance;
					}
					return _SupplierTotalBalance_W;
				}
			}

			public AggregateParameter SupplierPaidBalance
		    {
				get
		        {
					if(_SupplierPaidBalance_W == null)
	        	    {
						_SupplierPaidBalance_W = TearOff.SupplierPaidBalance;
					}
					return _SupplierPaidBalance_W;
				}
			}

			public AggregateParameter SupplierRemainBalance
		    {
				get
		        {
					if(_SupplierRemainBalance_W == null)
	        	    {
						_SupplierRemainBalance_W = TearOff.SupplierRemainBalance;
					}
					return _SupplierRemainBalance_W;
				}
			}

			private AggregateParameter _SupplierID_W = null;
			private AggregateParameter _SupplierName_W = null;
			private AggregateParameter _SupplierPhone_W = null;
			private AggregateParameter _SupplierTotalBalance_W = null;
			private AggregateParameter _SupplierPaidBalance_W = null;
			private AggregateParameter _SupplierRemainBalance_W = null;

			public void AggregateClauseReset()
			{
				_SupplierID_W = null;
				_SupplierName_W = null;
				_SupplierPhone_W = null;
				_SupplierTotalBalance_W = null;
				_SupplierPaidBalance_W = null;
				_SupplierRemainBalance_W = null;

				this._entity.Query.FlushAggregateParameters();

			}
	
			private BusinessEntity _entity;
			private TearOffAggregateParameter _tearOff;
			
		}
	
		public AggregateClause Aggregate
		{
			get
			{
				if(_aggregateClause == null)
				{
					_aggregateClause = new AggregateClause(this);
				}
		
				return _aggregateClause;
			}
		}
		
		private AggregateClause _aggregateClause = null;	
		#endregion
	
		protected override IDbCommand GetInsertCommand() 
		{
		
			SqlCommand cmd = new SqlCommand();
			cmd.CommandType = CommandType.StoredProcedure;
			cmd.CommandText = "[" + this.SchemaStoredProcedure + "proc_SuppliersInsert]";
	
			CreateParameters(cmd);
			
			SqlParameter p;
			p = cmd.Parameters[Parameters.SupplierID.ParameterName];
			p.Direction = ParameterDirection.Output;
    
			return cmd;
		}
	
		protected override IDbCommand GetUpdateCommand()
		{
		
			SqlCommand cmd = new SqlCommand();
			cmd.CommandType = CommandType.StoredProcedure;
			cmd.CommandText = "[" + this.SchemaStoredProcedure + "proc_SuppliersUpdate]";
	
			CreateParameters(cmd);
			      
			return cmd;
		}
	
		protected override IDbCommand GetDeleteCommand()
		{
		
			SqlCommand cmd = new SqlCommand();
			cmd.CommandType = CommandType.StoredProcedure;
			cmd.CommandText = "[" + this.SchemaStoredProcedure + "proc_SuppliersDelete]";
	
			SqlParameter p;
			p = cmd.Parameters.Add(Parameters.SupplierID);
			p.SourceColumn = ColumnNames.SupplierID;
			p.SourceVersion = DataRowVersion.Current;

  
			return cmd;
		}
		
		private IDbCommand CreateParameters(SqlCommand cmd)
		{
			SqlParameter p;
		
			p = cmd.Parameters.Add(Parameters.SupplierID);
			p.SourceColumn = ColumnNames.SupplierID;
			p.SourceVersion = DataRowVersion.Current;

			p = cmd.Parameters.Add(Parameters.SupplierName);
			p.SourceColumn = ColumnNames.SupplierName;
			p.SourceVersion = DataRowVersion.Current;

			p = cmd.Parameters.Add(Parameters.SupplierPhone);
			p.SourceColumn = ColumnNames.SupplierPhone;
			p.SourceVersion = DataRowVersion.Current;

			p = cmd.Parameters.Add(Parameters.SupplierTotalBalance);
			p.SourceColumn = ColumnNames.SupplierTotalBalance;
			p.SourceVersion = DataRowVersion.Current;

			p = cmd.Parameters.Add(Parameters.SupplierPaidBalance);
			p.SourceColumn = ColumnNames.SupplierPaidBalance;
			p.SourceVersion = DataRowVersion.Current;

			p = cmd.Parameters.Add(Parameters.SupplierRemainBalance);
			p.SourceColumn = ColumnNames.SupplierRemainBalance;
			p.SourceVersion = DataRowVersion.Current;


			return cmd;
		}
	}
}
